<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0028)http://jdbi.org/archive.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>


<title>abacus-common</title>

<script type="text/javascript" src="./css/ga.js"></script>
<script type="text/javascript">
	if (top.location != self.location)
		top.location.replace(self.location);
</script>

<link href="./css/css" rel="stylesheet" type="text/css"></link>
<link href="./css/css(1)" rel="stylesheet" type="text/css"></link>
<link rel="stylesheet" href="./css/syntax.css" type="text/css"></link>
<link rel="stylesheet" href="./css/screen.css" type="text/css"></link>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-65247258-1', 'auto');
  ga('send', 'pageview');
</script>

</head>
<body>
	<div id="site">
		<h1>
			<a href="./index.html">abacus-common</a> <span id="navigation"> <a href="./docs.html">Docs</a> | <a href="./download.html">Download</a>
				| <a href="./api-docs/index.html">Javadoc</a> | <a href="./faq.html">FAQ</a> | <a href="./community.html">Community</a>
			</span>
		</h1>
	</div>

	<div id="content">

		<div id="page">

			<h1>SQLExecutor</h1>
			<p>
				<a href="./SQLExecutor_view.html">SQLExecutor</a> is a general sql/jdbc utility class. 
				Insert/batchInsert/update/batchUpdate/delete/query and parameterized SQL with "?" or named parameters are supported very well.
				As one of the core functions provided by abacus-common. SQLExecutor is simple, fast and easy to use with the concise APIs.
				Here is the CRUD(create/read/update/delete) sample, comparing to the implementations by Jdbc, Spring JdbcTemplate, myBatis(iBatis), Hibernate and JPA:				
			</p>
			
			
			<li><b>CURD by SQLExecutor provided by abacus-common:</b> (See <a href="./jdbc-csv-util.html">JdbcUtil</a> about how to create DataSource for SQLExecutor)</li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudBySQLExecutor</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
    Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create</span>
    String sql_insert <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">insert</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> FIRST_NAME<span style="color: #666666">,</span> LAST_NAME<span style="color: #666666">,</span> LAST_UPDATE_TIME<span style="color: #666666">,</span> CREATE_TIME<span style="color: #666666">).</span><span style="color: #7D9029">into</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">insert</span><span style="color: #666666">(</span>sql_insert<span style="color: #666666">,</span> account<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// About how to initialize a SQLExecutor instance, refer to SQLExecutorTest.java in Helloabacus-common.</span>

    <span style="color: #408080; font-style: italic">// read</span>
    String sql_selectByGUI <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">selectFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asSet</span><span style="color: #666666">(</span>DEVICES<span style="color: #666666">)).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    Account dbAccount <span style="color: #666666">=</span> sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">queryForEntity</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> sql_selectByGUI<span style="color: #666666">,</span> account<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// update</span>
    String sql_updateByLastName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">set</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>sql_updateByLastName<span style="color: #666666">,</span> dbAccount<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    String sql_deleteByFirstName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">deleteFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>sql_deleteByFirstName<span style="color: #666666">,</span> dbAccount<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// check</span>
    dbAccount <span style="color: #666666">=</span> sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">queryForEntity</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> sql_selectByGUI<span style="color: #666666">,</span> dbAccount<span style="color: #666666">);</span>
    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>


			<p></p>	
			<li><b>CURD by ExMapper in SQLExecutor:</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crud</span><span style="color: #666666">()</span> <span style="color: #008000; font-weight: bold">throws</span> Exception <span style="color: #666666">{</span>
    <span style="color: #008000; font-weight: bold">final</span> ExMapper<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;</span> mapper <span style="color: #666666">=</span> sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">mapper</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
    <span style="color: #B00040">long</span> id <span style="color: #666666">=</span> mapper<span style="color: #666666">.</span><span style="color: #7D9029">add</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
    Account dbAccount <span style="color: #666666">=</span> mapper<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(</span>id<span style="color: #666666">,</span> selectPropNames<span style="color: #666666">);</span>

    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    mapper<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
    dbAccount <span style="color: #666666">=</span> mapper<span style="color: #666666">.</span><span style="color: #7D9029">queryForEntity</span><span style="color: #666666">(</span>selectPropNames<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;gui&quot;</span><span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">())).</span><span style="color: #7D9029">get</span><span style="color: #666666">();</span>
    assertEquals<span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>

    assertEquals<span style="color: #666666">(1,</span> mapper<span style="color: #666666">.</span><span style="color: #7D9029">delete</span><span style="color: #666666">(</span>dbAccount<span style="color: #666666">));</span>
<span style="color: #666666">}</span>
</pre></div>

			<p></p>
			<li><b>CURD by Jdbc with JdbcUtil:</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudByJdbc</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
    Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create</span>
    String sql_insert <span style="color: #666666">=</span> RE<span style="color: #666666">.</span><span style="color: #7D9029">insert</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> FIRST_NAME<span style="color: #666666">,</span> LAST_NAME<span style="color: #666666">,</span> LAST_UPDATE_TIME<span style="color: #666666">,</span> CREATE_TIME<span style="color: #666666">).</span><span style="color: #7D9029">into</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    Connection conn <span style="color: #666666">=</span> dataSource<span style="color: #666666">.</span><span style="color: #7D9029">getConnection</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">(</span>conn<span style="color: #666666">,</span> sql_insert<span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">(),</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">(),</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getLastName</span><span style="color: #666666">(),</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getLastUpdateTime</span><span style="color: #666666">(),</span>
                account<span style="color: #666666">.</span><span style="color: #7D9029">getCreateTime</span><span style="color: #666666">());</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">closeQuietly</span><span style="color: #666666">(</span>conn<span style="color: #666666">);</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// read</span>
    Account dbAccount <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    String sql_selectByGUI <span style="color: #666666">=</span> RE<span style="color: #666666">.</span><span style="color: #7D9029">selectFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asSet</span><span style="color: #666666">(</span>DEVICES<span style="color: #666666">)).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    conn <span style="color: #666666">=</span> dataSource<span style="color: #666666">.</span><span style="color: #7D9029">getConnection</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        DataSet rs <span style="color: #666666">=</span> JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">executeQuery</span><span style="color: #666666">(</span>conn<span style="color: #666666">,</span> sql_selectByGUI<span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
        dbAccount <span style="color: #666666">=</span> rs<span style="color: #666666">.</span><span style="color: #7D9029">size</span><span style="color: #666666">()</span> <span style="color: #666666">&gt;</span> <span style="color: #666666">0</span> <span style="color: #666666">?</span> rs<span style="color: #666666">.</span><span style="color: #7D9029">getRow</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> <span style="color: #666666">0)</span> <span style="color: #666666">:</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">closeQuietly</span><span style="color: #666666">(</span>conn<span style="color: #666666">);</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// update</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    String sql_updateByLastName <span style="color: #666666">=</span> RE<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">set</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    conn <span style="color: #666666">=</span> dataSource<span style="color: #666666">.</span><span style="color: #7D9029">getConnection</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">(</span>conn<span style="color: #666666">,</span> sql_updateByLastName<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">(),</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getLastName</span><span style="color: #666666">());</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">closeQuietly</span><span style="color: #666666">(</span>conn<span style="color: #666666">);</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    String sql_deleteByFirstName <span style="color: #666666">=</span> RE<span style="color: #666666">.</span><span style="color: #7D9029">deleteFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    conn <span style="color: #666666">=</span> dataSource<span style="color: #666666">.</span><span style="color: #7D9029">getConnection</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">(</span>conn<span style="color: #666666">,</span> sql_deleteByFirstName<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">closeQuietly</span><span style="color: #666666">(</span>conn<span style="color: #666666">);</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// check</span>
    conn <span style="color: #666666">=</span> dataSource<span style="color: #666666">.</span><span style="color: #7D9029">getConnection</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        DataSet rs <span style="color: #666666">=</span> JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">executeQuery</span><span style="color: #666666">(</span>conn<span style="color: #666666">,</span> sql_selectByGUI<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
        dbAccount <span style="color: #666666">=</span> rs<span style="color: #666666">.</span><span style="color: #7D9029">size</span><span style="color: #666666">()</span> <span style="color: #666666">&gt;</span> <span style="color: #666666">0</span> <span style="color: #666666">?</span> rs<span style="color: #666666">.</span><span style="color: #7D9029">getRow</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> <span style="color: #666666">0)</span> <span style="color: #666666">:</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        JdbcUtil<span style="color: #666666">.</span><span style="color: #7D9029">closeQuietly</span><span style="color: #666666">(</span>conn<span style="color: #666666">);</span>
    <span style="color: #666666">}</span>

    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>


			<p></p>
			<li><b>CURD by MyBatis:</b> (It's welcome to improve the code below)</li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">interface</span> <span style="color: #0000FF; font-weight: bold">AccountMapper</span> <span style="color: #666666">{</span>
    <span style="color: #AA22FF">@Insert</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;INSERT INTO account (gui, first_name, last_name, last_update_time, create_time) VALUES (#{gui}, #{firstName}, #{lastName}, #{lastUpdateTime}, #{createTime})&quot;</span><span style="color: #666666">)</span>
    <span style="color: #B00040">void</span> <span style="color: #0000FF">insertAccount</span><span style="color: #666666">(</span>Account account<span style="color: #666666">);</span>

    <span style="color: #AA22FF">@Select</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;SELECT id AS \&quot;id\&quot;, gui AS \&quot;gui\&quot;, first_name AS \&quot;firstName\&quot;, last_name AS \&quot;lastName\&quot;, status AS \&quot;status\&quot;, last_update_time AS \&quot;lastUpdateTime\&quot;, create_time AS \&quot;createTime\&quot; FROM account WHERE gui = #{gui}&quot;</span><span style="color: #666666">)</span>
    Account <span style="color: #0000FF">getAccountByGUI</span><span style="color: #666666">(</span>String gui<span style="color: #666666">);</span>

    <span style="color: #AA22FF">@Update</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;UPDATE account SET first_name = #{firstName} WHERE last_name = #{lastName}&quot;</span><span style="color: #666666">)</span>
    <span style="color: #B00040">int</span> <span style="color: #0000FF">updateByLastName</span><span style="color: #666666">(</span>Account account<span style="color: #666666">);</span>

    <span style="color: #AA22FF">@Delete</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;DELETE FROM account WHERE first_name = #{firstName}&quot;</span><span style="color: #666666">)</span>
    <span style="color: #B00040">int</span> <span style="color: #0000FF">deleteByFirstName</span><span style="color: #666666">(</span>Account account<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudByMyBatis</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
    Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create</span>
    SqlSession session <span style="color: #666666">=</span> sqlSessionFactory<span style="color: #666666">.</span><span style="color: #7D9029">openSession</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">);</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        AccountMapper accountMapper <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">getMapper</span><span style="color: #666666">(</span>AccountMapper<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        accountMapper<span style="color: #666666">.</span><span style="color: #7D9029">insertAccount</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// read</span>
    Account dbAccount <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    session <span style="color: #666666">=</span> sqlSessionFactory<span style="color: #666666">.</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        AccountMapper accountMapper <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">getMapper</span><span style="color: #666666">(</span>AccountMapper<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        dbAccount <span style="color: #666666">=</span> accountMapper<span style="color: #666666">.</span><span style="color: #7D9029">getAccountByGUI</span><span style="color: #666666">(</span>account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// update</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    session <span style="color: #666666">=</span> sqlSessionFactory<span style="color: #666666">.</span><span style="color: #7D9029">openSession</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">);</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        AccountMapper accountMapper <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">getMapper</span><span style="color: #666666">(</span>AccountMapper<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        accountMapper<span style="color: #666666">.</span><span style="color: #7D9029">updateByLastName</span><span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    session <span style="color: #666666">=</span> sqlSessionFactory<span style="color: #666666">.</span><span style="color: #7D9029">openSession</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">);</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        AccountMapper accountMapper <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">getMapper</span><span style="color: #666666">(</span>AccountMapper<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        accountMapper<span style="color: #666666">.</span><span style="color: #7D9029">deleteByFirstName</span><span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// check</span>
    session <span style="color: #666666">=</span> sqlSessionFactory<span style="color: #666666">.</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        AccountMapper accountMapper <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">getMapper</span><span style="color: #666666">(</span>AccountMapper<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        dbAccount <span style="color: #666666">=</span> accountMapper<span style="color: #666666">.</span><span style="color: #7D9029">getAccountByGUI</span><span style="color: #666666">(</span>dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>



			<p></p>
			<li><b>CURD by Hibernate:</b> (It's welcome to improve the code below)</li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudByHibernateSession</span><span style="color: #666666">()</span> <span style="color: #008000; font-weight: bold">throws</span> Exception <span style="color: #666666">{</span>
    Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create</span>
    Session session <span style="color: #666666">=</span> HibernateUtil<span style="color: #666666">.</span><span style="color: #7D9029">getSessionFactory</span><span style="color: #666666">().</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">save</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// read</span>
    Account dbAccount <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    session <span style="color: #666666">=</span> HibernateUtil<span style="color: #666666">.</span><span style="color: #7D9029">getSessionFactory</span><span style="color: #666666">().</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        List<span style="color: #666666">&lt;?&gt;</span> list <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">createCriteria</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">add</span><span style="color: #666666">(</span>Restrictions<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;GUI&quot;</span><span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">())).</span><span style="color: #7D9029">list</span><span style="color: #666666">();</span>
        dbAccount <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">isNullOrEmpty</span><span style="color: #666666">(</span>list<span style="color: #666666">)</span> <span style="color: #666666">?</span> <span style="color: #008000; font-weight: bold">null</span> <span style="color: #666666">:</span> <span style="color: #666666">(</span>Account<span style="color: #666666">)</span> list<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(0);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// update</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    String sql_updateByLastName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;Account&quot;</span><span style="color: #666666">).</span><span style="color: #7D9029">set</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    session <span style="color: #666666">=</span> HibernateUtil<span style="color: #666666">.</span><span style="color: #7D9029">getSessionFactory</span><span style="color: #666666">().</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        Query query <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">createSQLQuery</span><span style="color: #666666">(</span>sql_updateByLastName<span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setString</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setString</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getLastName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    String sql_deleteByFirstName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">deleteFrom</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;Account&quot;</span><span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    session <span style="color: #666666">=</span> HibernateUtil<span style="color: #666666">.</span><span style="color: #7D9029">getSessionFactory</span><span style="color: #666666">().</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        Query query <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">createSQLQuery</span><span style="color: #666666">(</span>sql_deleteByFirstName<span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setString</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// check</span>
    session <span style="color: #666666">=</span> HibernateUtil<span style="color: #666666">.</span><span style="color: #7D9029">getSessionFactory</span><span style="color: #666666">().</span><span style="color: #7D9029">openSession</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        List<span style="color: #666666">&lt;?&gt;</span> list <span style="color: #666666">=</span> session<span style="color: #666666">.</span><span style="color: #7D9029">createCriteria</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">add</span><span style="color: #666666">(</span>Restrictions<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;GUI&quot;</span><span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">())).</span><span style="color: #7D9029">list</span><span style="color: #666666">();</span>
        dbAccount <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">isNullOrEmpty</span><span style="color: #666666">(</span>list<span style="color: #666666">)</span> <span style="color: #666666">?</span> <span style="color: #008000; font-weight: bold">null</span> <span style="color: #666666">:</span> <span style="color: #666666">(</span>Account<span style="color: #666666">)</span> list<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(0);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        session<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>




			<p></p>
			<li><b>CURD by Spring JdbcTemplate:</b> (It's welcome to improve the code below)</li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudBySpringJdbc</span><span style="color: #666666">()</span> <span style="color: #008000; font-weight: bold">throws</span> Exception <span style="color: #666666">{</span>
    <span style="color: #008000; font-weight: bold">final</span> ResultSetExtractor<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;</span> resultSetExtractor <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> ResultSetExtractor<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;()</span> <span style="color: #666666">{</span>
        <span style="color: #AA22FF">@Override</span>
        <span style="color: #008000; font-weight: bold">public</span> Account <span style="color: #0000FF">extractData</span><span style="color: #666666">(</span>ResultSet rs<span style="color: #666666">)</span> <span style="color: #008000; font-weight: bold">throws</span> SQLException<span style="color: #666666">,</span> DataAccessException <span style="color: #666666">{</span>
            <span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">next</span><span style="color: #666666">())</span> <span style="color: #666666">{</span>
                Account act <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> Account<span style="color: #666666">();</span>
                <span style="color: #B00040">int</span> columnIndex <span style="color: #666666">=</span> <span style="color: #666666">1;</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setId</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getLong</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setGUI</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getString</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getString</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setLastName</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getString</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setStatus</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getInt</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setLastUpdateTime</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getTimestamp</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>
                act<span style="color: #666666">.</span><span style="color: #7D9029">setCreateTime</span><span style="color: #666666">(</span>rs<span style="color: #666666">.</span><span style="color: #7D9029">getTimestamp</span><span style="color: #666666">(</span>columnIndex<span style="color: #666666">++));</span>

                <span style="color: #008000; font-weight: bold">return</span> act<span style="color: #666666">;</span>
            <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">else</span> <span style="color: #666666">{</span>
                <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
            <span style="color: #666666">}</span>
        <span style="color: #666666">}</span>
    <span style="color: #666666">};</span>

    <span style="color: #008000; font-weight: bold">final</span> Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create</span>
    <span style="color: #008000; font-weight: bold">final</span> String sql_insert <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">insert</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> FIRST_NAME<span style="color: #666666">,</span> LAST_NAME<span style="color: #666666">,</span> LAST_UPDATE_TIME<span style="color: #666666">,</span> CREATE_TIME<span style="color: #666666">).</span><span style="color: #7D9029">into</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    Map<span style="color: #666666">&lt;</span>String<span style="color: #666666">,</span> Object<span style="color: #666666">&gt;</span> parameters <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">entity2Map</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
    namedJdbcTemplate<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>sql_insert<span style="color: #666666">,</span> parameters<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// read</span>
    String sql_selectByGUI <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">selectFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asSet</span><span style="color: #666666">(</span>DEVICES<span style="color: #666666">)).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    Account dbAccount <span style="color: #666666">=</span> namedJdbcTemplate<span style="color: #666666">.</span><span style="color: #7D9029">query</span><span style="color: #666666">(</span>sql_selectByGUI<span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asProps</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;gui&quot;</span><span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">()),</span> resultSetExtractor<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// update</span>
    String sql_updateByLastName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">set</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    parameters <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asProps</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">(),</span> LAST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getLastName</span><span style="color: #666666">());</span>
    namedJdbcTemplate<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>sql_updateByLastName<span style="color: #666666">,</span> parameters<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    String sql_deleteByFirstName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">deleteFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    namedJdbcTemplate<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>sql_deleteByFirstName<span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asProps</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">()));</span>

    dbAccount <span style="color: #666666">=</span> sqlExecutor<span style="color: #666666">.</span><span style="color: #7D9029">queryForEntity</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> sql_selectByGUI<span style="color: #666666">,</span> dbAccount<span style="color: #666666">);</span>
    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>

    <span style="color: #408080; font-style: italic">// check</span>
    dbAccount <span style="color: #666666">=</span> namedJdbcTemplate<span style="color: #666666">.</span><span style="color: #7D9029">query</span><span style="color: #666666">(</span>sql_selectByGUI<span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asProps</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">()),</span> resultSetExtractor<span style="color: #666666">);</span>

    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>



			
			<p></p>
			<li><b>CURD by JPA:</b> (It's welcome to improve the code below)</li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #AA22FF">@Test</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">test_crudByHibernateJPA</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
    <span style="color: #008000; font-weight: bold">final</span> Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">();</span>

    <span style="color: #408080; font-style: italic">// create;</span>
    EntityManager entityManager <span style="color: #666666">=</span> hibernateEntityManagerFactory<span style="color: #666666">.</span><span style="color: #7D9029">createEntityManager</span><span style="color: #666666">();</span>
    entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">begin</span><span style="color: #666666">();</span>
    <span style="color: #B00040">boolean</span> noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">false</span><span style="color: #666666">;</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        entityManager<span style="color: #666666">.</span><span style="color: #7D9029">persist</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
        noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">;</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
            <span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>noException<span style="color: #666666">)</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">commit</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">else</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">rollback</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span>
        <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
            entityManager<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
        <span style="color: #666666">}</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// read</span>
    Account dbAccount <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">;</span>
    String sql_selectByGUI <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">selectFrom</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asSet</span><span style="color: #666666">(</span>DEVICES<span style="color: #666666">)).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    entityManager <span style="color: #666666">=</span> hibernateEntityManagerFactory<span style="color: #666666">.</span><span style="color: #7D9029">createEntityManager</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        javax<span style="color: #666666">.</span><span style="color: #7D9029">persistence</span><span style="color: #666666">.</span><span style="color: #7D9029">Query</span> query <span style="color: #666666">=</span> entityManager<span style="color: #666666">.</span><span style="color: #7D9029">createNativeQuery</span><span style="color: #666666">(</span>sql_selectByGUI<span style="color: #666666">,</span> Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setParameter</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> account<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
        List<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;</span> resultList <span style="color: #666666">=</span> query<span style="color: #666666">.</span><span style="color: #7D9029">getResultList</span><span style="color: #666666">();</span>
        dbAccount <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">isNullOrEmpty</span><span style="color: #666666">(</span>resultList<span style="color: #666666">)</span> <span style="color: #666666">?</span> <span style="color: #008000; font-weight: bold">null</span> <span style="color: #666666">:</span> resultList<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(0);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        entityManager<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// update</span>
    dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">setFirstName</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;newFirstName&quot;</span><span style="color: #666666">);</span>
    String sql_updateByLastName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">update</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">).</span><span style="color: #7D9029">set</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    entityManager <span style="color: #666666">=</span> hibernateEntityManagerFactory<span style="color: #666666">.</span><span style="color: #7D9029">createEntityManager</span><span style="color: #666666">();</span>
    entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">begin</span><span style="color: #666666">();</span>
    noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">false</span><span style="color: #666666">;</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        javax<span style="color: #666666">.</span><span style="color: #7D9029">persistence</span><span style="color: #666666">.</span><span style="color: #7D9029">Query</span> query <span style="color: #666666">=</span> entityManager<span style="color: #666666">.</span><span style="color: #7D9029">createNativeQuery</span><span style="color: #666666">(</span>sql_updateByLastName<span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setParameter</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setParameter</span><span style="color: #666666">(</span>LAST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getLastName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">();</span>

        noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">;</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
            <span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>noException<span style="color: #666666">)</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">commit</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">else</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">rollback</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span>
        <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
            entityManager<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
        <span style="color: #666666">}</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// delete</span>
    String sql_deleteByFirstName <span style="color: #666666">=</span> NE<span style="color: #666666">.</span><span style="color: #7D9029">deleteFrom</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;Account&quot;</span><span style="color: #666666">).</span><span style="color: #7D9029">where</span><span style="color: #666666">(</span>L<span style="color: #666666">.</span><span style="color: #7D9029">eq</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> L<span style="color: #666666">.</span><span style="color: #7D9029">QME</span><span style="color: #666666">)).</span><span style="color: #7D9029">sql</span><span style="color: #666666">();</span>
    entityManager <span style="color: #666666">=</span> hibernateEntityManagerFactory<span style="color: #666666">.</span><span style="color: #7D9029">createEntityManager</span><span style="color: #666666">();</span>
    entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">begin</span><span style="color: #666666">();</span>
    noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">false</span><span style="color: #666666">;</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        javax<span style="color: #666666">.</span><span style="color: #7D9029">persistence</span><span style="color: #666666">.</span><span style="color: #7D9029">Query</span> query <span style="color: #666666">=</span> entityManager<span style="color: #666666">.</span><span style="color: #7D9029">createNativeQuery</span><span style="color: #666666">(</span>sql_deleteByFirstName<span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setParameter</span><span style="color: #666666">(</span>FIRST_NAME<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">executeUpdate</span><span style="color: #666666">();</span>

        noException <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">;</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
            <span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>noException<span style="color: #666666">)</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">commit</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">else</span> <span style="color: #666666">{</span>
                entityManager<span style="color: #666666">.</span><span style="color: #7D9029">getTransaction</span><span style="color: #666666">().</span><span style="color: #7D9029">rollback</span><span style="color: #666666">();</span>
            <span style="color: #666666">}</span>
        <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
            entityManager<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
        <span style="color: #666666">}</span>
    <span style="color: #666666">}</span>

    <span style="color: #408080; font-style: italic">// check</span>
    entityManager <span style="color: #666666">=</span> hibernateEntityManagerFactory<span style="color: #666666">.</span><span style="color: #7D9029">createEntityManager</span><span style="color: #666666">();</span>

    <span style="color: #008000; font-weight: bold">try</span> <span style="color: #666666">{</span>
        javax<span style="color: #666666">.</span><span style="color: #7D9029">persistence</span><span style="color: #666666">.</span><span style="color: #7D9029">Query</span> query <span style="color: #666666">=</span> entityManager<span style="color: #666666">.</span><span style="color: #7D9029">createNativeQuery</span><span style="color: #666666">(</span>sql_selectByGUI<span style="color: #666666">,</span> Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
        query<span style="color: #666666">.</span><span style="color: #7D9029">setParameter</span><span style="color: #666666">(</span>GUI<span style="color: #666666">,</span> dbAccount<span style="color: #666666">.</span><span style="color: #7D9029">getGUI</span><span style="color: #666666">());</span>
        List<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;</span> resultList <span style="color: #666666">=</span> query<span style="color: #666666">.</span><span style="color: #7D9029">getResultList</span><span style="color: #666666">();</span>
        dbAccount <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">isNullOrEmpty</span><span style="color: #666666">(</span>resultList<span style="color: #666666">)</span> <span style="color: #666666">?</span> <span style="color: #008000; font-weight: bold">null</span> <span style="color: #666666">:</span> resultList<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(0);</span>
    <span style="color: #666666">}</span> <span style="color: #008000; font-weight: bold">finally</span> <span style="color: #666666">{</span>
        entityManager<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
    <span style="color: #666666">}</span>

    assertNull<span style="color: #666666">(</span>dbAccount<span style="color: #666666">);</span>
<span style="color: #666666">}</span>
</pre></div>

			<p></p>
			<p>As you see, There is no setting or conversion... in <i>test_crudBySQLExecutor</i>. All are done by SQLBuilder/SQLExecutor automatically. 
			You have the full control of the SQL in hand, and will be able to focus on the logic to write the most effient SQL with the talent you have.</p>

			<p></p>
			<p>Finally, let's take a look at the performance test running on a laptop with: CPU: Intel i7-3520M 2.9GHz, Meory: 8G, OS: Windows 7 64-bit, JDK: 1.7.0_80, Database: h2-1.3.176:</p>
			
			<p></p>
			<p>Test Result: (unit: milliseconds)</p>			
========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 9670
<br/>
<br/>maxMethodTime(test_crudBySQLExecutor): 129
<br/>minMethodTime(test_crudBySQLExecutor): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>0.9212</td>
<td>0</td>
<td>129</td>
<td>79</td>
<td>4</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================

========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 8467
<br/>
<br/>maxMethodTime(test_crudByJdbc): 141
<br/>minMethodTime(test_crudByJdbc): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>0.7889</td>
<td>0</td>
<td>141</td>
<td>108</td>
<td>4</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================
========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 10015
<br/>
<br/>maxMethodTime(test_crudBySpringJdbc): 74
<br/>minMethodTime(test_crudBySpringJdbc): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>0.9495</td>
<td>0</td>
<td>74</td>
<td>52</td>
<td>4</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================
========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 18455
<br/>
<br/>maxMethodTime(test_crudByMyBatis): 101
<br/>minMethodTime(test_crudByMyBatis): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>1.6955</td>
<td>0</td>
<td>101</td>
<td>46</td>
<td>8</td>
<td>4</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================
========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 17048
<br/>
<br/>maxMethodTime(test_crudByHibernateSession): 148
<br/>minMethodTime(test_crudByHibernateSession): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>1.5853</td>
<td>0</td>
<td>148</td>
<td>53</td>
<td>6</td>
<td>3</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================
========================================================================================================================
<br/>threadNum=6; loops=10000
<br/>totalElapsedTime: 22742
<br/>
<br/>maxMethodTime(test_crudByHibernateJPA): 67
<br/>minMethodTime(test_crudByHibernateJPA): 0
<br/>
<table width="600" border="1">
<tr>
<th>method name</th>
<th>avg time</th>
<th>min time</th>
<th>max time</th>
<th>0.01% &gt;=</th>
<th>0.1% &gt;=</th>
<th>1% &gt;=</th>
<th>10% &gt;=</th>
<th>20% &gt;=</th>
<th>50% &gt;=</th>
<th>80% &gt;=</th>
<th>90% &gt;=</th>
<th>99% &gt;=</th>
<th>99.9% &gt;=</th>
<th>99.99% &gt;=</th>
</tr>
<tr>
<td>...</td>
<td>2.2477</td>
<td>0</td>
<td>67</td>
<td>50</td>
<td>6</td>
<td>5</td>
<td>3</td>
<td>3</td>
<td>2</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
</table>
========================================================================================================================
		</div>

	</div>
</body>

</html>